﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MxitAPI;

namespace MxitGUI {
    public partial class UserProfileWindow : Form {
        public UserProfileWindow() {
            InitializeComponent();
            Init();
        }

        private void Init() {
            UserProfile userProfile = UserProfile.Instance;
            txtDateOfBirth.Text = userProfile.DateOfBirth;
            txtNickName.Text = userProfile.Name;

            cmbGender.Items.Add( Gender.Female );
            cmbGender.Items.Add( Gender.Male );
            cmbGender.SelectedItem = userProfile.Gender;

            cmbHideUserName.Items.Add( "Yes" );
            cmbHideUserName.Items.Add( "No" );
            if ( userProfile.LoginNameHidden )
                cmbHideUserName.SelectedIndex = 0;
            else
                cmbHideUserName.SelectedIndex = 1;

        }

        private void btnSave_Click( object sender, EventArgs e ) {
            bool hideUserName = false;
            if ( cmbHideUserName.SelectedIndex == 0 )
                hideUserName = true;

            new UpdateProfileHandler( txtPassword.Text, txtNickName.Text, hideUserName, txtDateOfBirth.Text, ( Gender )cmbGender.SelectedItem ).Execute();
            new GetProfileHandler().Execute();
            DialogResult = DialogResult.OK;
            Close();
        }

        private void btnCancel_Click( object sender, EventArgs e ) {
            DialogResult = DialogResult.Cancel;
            Close();
        }
    }
}
